#!/bin/bash

DATE=`date "+%F_%T"`

USER_FILE=list_user



if [[ -f ${USER_FILE} ]];then
   mv ${USER_FILE} ${USER_FILE}-${DATE}.bak


fi

echo -e "User\t Password" >> ${USER_FILE}
echo "----------------" >> ${USER_FILE}


for user in ixdba{1..10}
do
   if ! id ${user} &>/dev/null
   #if [[  `id ${user}` == ""  ]] && &>/dev/null
   then
        PASS=$(echo ${RANDOM} |md5sum | cut -c 1-8)
        useradd ${user}
        echo -e ${PASS} | passwd --stdin ${user} &>/dev/null
        echo -e "${user}\t ${PASS}" >> ${USER_FILE}
        echo -e "${user} 用户创建成功"
   fi
done
